<?php

###########################################################################
#   Copyright (C) 2012 CDNPAL LTD by Christopher Gu                       #
#   resources@cdnpal.com                                                  #
#                                                                         #
#   coded for Php 4.3/5.X and above                                       #
#   and AllowOverride all for .htaccess                                   #
#                                                                         #
#   This program is free software released                                #
#   under the GPL version 2 license:                                      #
#   http://www.gnu.org/licenses/gpl-2.0.htm                               #
#                                                                         #
#   This program is distributed WITHOUT ANY WARRANTY                      #
#   or FITNESS FOR A PARTICULAR PURPOSE.                                  #
#                                                                         #
#   DADF-SDK                                                              #
#                                                                         #
###########################################################################

class Dadf2XMLService
{
	public static function convert_bid_request($id, $table_direction = 'Outgoing') {
		
		header("Content-type: text/xml");
		
		try {
			
			$transformer = new OutgoingRequestTransformer($id, "", $table_direction);
	    	echo $transformer->xmlData;
	    	
		} catch (Exception $e) {
			
			$message = '<error><message>' . $e->getMessage() . '</message></error>';
			echo $message;
		}
	}
	
	public static function convert_offer_response($id, $table_direction = 'Outgoing') {
		
		header("Content-type: text/xml");
		
		try {
			$transformer = new OutgoingOfferTransformer($id, $table_direction);
	    	echo $transformer->xmlData;
	    	
		} catch (Exception $e) {
			
			$message = '<error><message>' . $e->getMessage() . '</message></error>';
			echo $message;
		}
	}
	
	public static function convert_accept_response($id, $table_direction = 'Outgoing') {
		
		header("Content-type: text/xml");
		
		try {
			$transformer = new OutgoingAcceptTransformer($id, "", 0, $table_direction);
	    	echo $transformer->xmlData;
	    	
		} catch (Exception $e) {
			
			$message = '<error><message>' . $e->getMessage() . '</message></error>';
			echo $message;
		}
	}
	
	public static function convert_accepted_response($id, $table_direction = 'Outgoing') {
		
		header("Content-type: text/xml");
		
		try {
			$transformer = new OutgoingAcceptedTransformer($id, 0, $table_direction);
	    	echo $transformer->xmlData;
	    	
		} catch (Exception $e) {
			
			$message = '<error><message>' . $e->getMessage() . '</message></error>';
			echo $message;
		}
	}
	
}